package action;

import board.BoardUtil;
import board.PatternType;
import character.CharacterUtil;
import character.MyCharacter;
import java.util.List;
import misc.Vector3i;

public class ActionApproach extends Action {
    protected MyCharacter destination;
    protected PatternType rangePattern;
    protected int rangeSize;

    @Deprecated
    protected ActionApproach() {}
    
    public ActionApproach(MyCharacter character, MyCharacter destination, PatternType rangePattern, int rangeSize) {
        super(true, character, -1);
        this.destination = destination;
        this.rangePattern = rangePattern;
        this.rangeSize = rangeSize;
    }

    @Override
    protected void start() {
        System.out.println("Beginning approach...");
    }

    @Override
    protected boolean tick() {
        if(!CharacterUtil.checkCharacterInRange(character, destination, rangePattern, rangeSize)) {
            List<Vector3i> travelPath = BoardUtil.findPath(character.getBoardLocation(), destination.getBoardLocation(), character.getCharacterStats().getMoveSpeedWithModifier(), character.getCharacterStats().getDiagonalMoveSpeedWithModifier());
            charControl.queueActionFirst(new ActionMove(character, travelPath.get(0)));
        } else {
            completeAction();
        }
        return false; //this action shouldn't use up any ticks/allow other listeners to tick
    }

    @Override
    protected void complete() {}

    @Override
    protected void abort() {}

    @Override
    public void pause() {}

    @Override
    public void unpause() {}
}
